<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page
	import="org.ejb.entities.*,org.ejb.api.*, javax.naming.*, java.util.*"%>

<%
  BookCatalogInterface bci=null ;
  String s1,s2,s3;
  Collection list;
  

  try{
  InitialContext ic = new InitialContext();
    bci = (BookCatalogInterface) ic.lookup("org.ejb.stateless.BookCatalogBean@Remote");

  System.out.println("Loaded Bank Bean");

  } catch (Exception ex) {
  System.out.println("Error:"+
  ex.getMessage());
  }


  try {
  s1 = request.getParameter("t1");
  s2 = request.getParameter("aut");
  s3 = request.getParameter("price");

  if ( s1 != null && s2 != null && s3 != null) {
  Double price= new Double(s3);
  bci.addBook(s1, s2, price.doubleValue());
  System.out.println("Record added:");
 %>
  <p>
  <b>Record added</b> 
  <p>
  
  <%
  }
  list=bci.getAllBooks();
  for(Iterator iter = list.iterator(); iter.hasNext();){
  BookBank element = (BookBank)iter.next();
  %>
  <br>
 <p>Book ID: <b><%= element.getId() %></b></p>
  <p>Title: <b><%= element.getTitle() %></b></p>
  <p>Author: <b><%= element.getAuthor() %></b></p>
  <p>Price: <b><%= element.getPrice() %></b></p>

  <%
  }
  }// end of try
  catch (Exception e) {
  e.printStackTrace ();
  }
  %>